import style from './style.css';
import React, { Component } from 'react';
import { Radio } from 'antd';

const RadioBtn = Radio.Button;
const RadioGroup = Radio.Group;

// export const RadioButton = (props)=>{
//     const RadioButton = Radio.Button;
//     const RadioGroup = Radio.Group;
//     const keyset = props.keyset;
//     let radioArray = [];
//     for(let i=0;i<keyset.length;i++){
//         radioArray.push(<RadioButton value={keyset[i]['value']}>{keyset[i]['name']}</RadioButton>)
//     }
//     return(
//         <RadioGroup
//         onChange = {()=>this.props.onChange(value)}>
//             {radioArray}
//         </RadioGroup>
//     )
// }
export const RadioButton = class extends Component {
    constructor(props) {
        super(props);
        this.keyset = props.keyset;
        this.style = props.style ? props.style : '';
    }
    render() {
        let radioArray = [];
        for (let i = 0; i < this.keyset.length; i++) {
            radioArray.push(<RadioBtn value={this.keyset[i]['value']}>{this.keyset[i]['name']}</RadioBtn>)
        }
        return (
            <RadioGroup style={this.style} className = {style.sxqRadioGroup}
                onChange={(value) => this.props.onRadioChange(value)}>
                {radioArray}
            </RadioGroup>
        )
    }
}